layui.config({
	base : "js/"
}).use(['form','layer'],function(){
	var form = layui.form(),
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		$ = layui.jquery;
	//video背景
	$(window).resize(function(){
		if($(".video-player").width() > $(window).width()){
			$(".video-player").css({"height":$(window).height(),"width":"auto","left":-($(".video-player").width()-$(window).width())/2});
		}else{
			$(".video-player").css({"width":$(window).width(),"height":"auto","left":-($(".video-player").width()-$(window).width())/2});
		}
	}).resize();
	
	//登录按钮事件
	form.on("submit(login)",function(data){
		var dto =
		{
			"loginName":$(".loginName").val(),
			"userPwd":$(".userPwd").val()
		}
		$.ajax({
	        url: API_URL_HEAD+"sysUser/login",
	        type: 'post',	
	        contentType: "application/json; charset=utf-8",
	        data: JSON.stringify(dto),
	        dataType: 'json',
	        success: function (data) {
	            if(data.code == 0){
	               //刷新父页面 
	               var result = data.data;
	               if(result != null)
	               {
	               	//写入cookie
					var exp = new Date();
					
					//exp.setTime(exp.getTime() + 1000 * 60 * 60 * 24); //这里表示保存24小时
					document.cookie = "music_identify=" + $(".loginName").val() + ";expires=";
					document.cookie = "music_key_code=" + $(".userPwd").val() + ";expires=";;
					window.sessionStorage.setItem("userInfo",JSON.stringify(result));
	               	window.location.href = "index.html";
	               }else
	               {
	               	$("#errorTips").removeClass("layui-hide");
	               	$("#errorTips").text("账号或密码错误，请重新输入！");
	               }
	            }else
	            {
	            	$("#errorTips").removeClass("layui-hide");
	               	$("#errorTips").text("账号或密码错误，请重新输入！");
	            }
	        }
    	});
		return false;
	})
})
